#include "NetElevatorAuthorizeCmd.h"

NetElevatorAuthorizeCmd::NetElevatorAuthorizeCmd(QObject *parent) :
    BaseCmd(parent)
{
    this->m_protocolType = ProtocolType::NetPointProtocol;
    this->m_functionCode = FunctionCode;
    m_roomNumber = 0;
    m_storeyNumber=0;
    m_floorNumber="";
}

Package NetElevatorAuthorizeCmd::toPackage()
{
    Package package;
    QByteArray body;

    body.append(DataTypeConver::intToByteArray(m_roomNumber,4));
\

    package.setFunction(FunctionCode);
    package.setBody(body);
    return package;
}

void NetElevatorAuthorizeCmd::unPackage(Package package)
{
    qDebug()<<"NetElevatorAuthorizeCmd::unPackage--"<<DataTypeConver::formatString(package.body());
    m_roomFloorNumber = DataTypeConver::formatString(package.body().mid(2,1));
    qDebug()<<"m_roomFloorNumber--"<<m_roomFloorNumber;
    m_roomNumber  = package.body().mid(2,2).toHex().toInt(0,16);
    m_floorNumber = QString(package.body().mid(4,1));
    m_extNumber = QString(package.body().mid(5));
    qDebug()<<"unPackage-m_floorNumber"<<m_floorNumber;
}

QString NetElevatorAuthorizeCmd::roomFloorNumber() const
{
    return m_roomFloorNumber;
}
void NetElevatorAuthorizeCmd::setRoomFloorNumber(const QString floor)
{
    m_roomFloorNumber = floor;
}

QString NetElevatorAuthorizeCmd::doorExtNumber() const
{
    return m_extNumber;
}
void NetElevatorAuthorizeCmd::setDoorExtNumber(const QString ext)
{
    m_extNumber = ext;
}

quint16 NetElevatorAuthorizeCmd::roomNumber() const
{
    return m_roomNumber;
}

void NetElevatorAuthorizeCmd::setRoomNumber(const quint16 &num)
{
    m_roomNumber=num;
}

QString NetElevatorAuthorizeCmd::floorNumber() const
{
    return m_floorNumber;
}

void NetElevatorAuthorizeCmd::setFloorNumber(const quint16 &num)
{
    m_floorNumber=num;
}


quint16 NetElevatorAuthorizeCmd::storeyNumber() const
{
    return m_storeyNumber;
}

void NetElevatorAuthorizeCmd::setStoreyNumber(const quint16 &num)
{
    m_storeyNumber=num;
}



